import uuid
from dataclasses import dataclass
from typing import Any, TypeVar

import pytest
from sqlalchemy import insert
from sqlalchemy.ext.asyncio import AsyncSession

from recruit.adapter.database.models import Resume

UserTest = TypeVar('UserTest')


@dataclass
class ResumeTest:
    id: uuid.uuid4()
    user_id: uuid.uuid4()


@pytest.fixture
async def create_resume(
        create_user: UserTest,
        db_session: AsyncSession,
        get_resume: dict[str, Any]
) -> ResumeTest:
    get_resume['user_id'] = create_user.id
    stmt = insert(Resume).values(get_resume).returning(Resume)
    result = (await db_session.execute(stmt)).scalar_one()
    resume = ResumeTest(
        id=result.id,
        user_id=result.user_id
    )
    await db_session.commit()
    return resume
